home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / spacefb.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  4KB  |  158 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12.  
  13. static int video_control;
  14.  
  15.  
  16. /***************************************************************************
  17.  
  18.   Convert the color PROMs into a more useable format.
  19.  
  20.   Space FB has one 32 bytes palette PROM, connected to the RGB output this
  21.   way:
  22.  
  23.   bit 7 -- 220 ohm resistor  -- BLUE
  24.         -- 470 ohm resistor  -- BLUE
  25.         -- 220 ohm resistor  -- GREEN
  26.         -- 470 ohm resistor  -- GREEN
  27.         -- 1  kohm resistor  -- GREEN
  28.         -- 220 ohm resistor  -- RED
  29.         -- 470 ohm resistor  -- RED
  30.   bit 0 -- 1  kohm resistor  -- RED
  31.  
  32. ***************************************************************************/
  33. void spacefb_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  34. {
  35.     int i;
  36.  
  37.     for (i = 0;i < 32;i++)
  38.     {
  39.         int bit0,bit1,bit2;
  40.  
  41.         bit0 = (color_prom[i] >> 0) & 0x01;
  42.         bit1 = (color_prom[i] >> 1) & 0x01;
  43.         bit2 = (color_prom[i] >> 2) & 0x01;
  44.         palette[3*i + 0] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  45.         bit0 = (color_prom[i] >> 3) & 0x01;
  46.         bit1 = (color_prom[i] >> 4) & 0x01;
  47.         bit2 = (color_prom[i] >> 5) & 0x01;
  48.         palette[3*i + 1] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  49.         bit0 = 0;
  50.         bit1 = (color_prom[i] >> 6) & 0x01;
  51.         bit2 = (color_prom[i] >> 7) & 0x01;
  52.         if (bit1 | bit2)
  53.             bit0 = 1;
  54.         palette[3*i + 2] = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
  55.     }
  56.  
  57.     for (i = 0;i < 4 * 8;i++)
  58.     {
  59.         if (i & 3) colortable[i] = i;
  60.         else colortable[i] = 0;
  61.     }
  62. }
  63.  
  64.  
  65. WRITE_HANDLER( spacefb_video_control_w )
  66. {
  67.     video_control = data;
  68. }
  69.  
  70.  
  71. WRITE_HANDLER( spacefb_port_2_w )
  72. {
  73. logerror("Port #2 = %02d\n",data);
  74. }
  75.  
  76.  
  77. /***************************************************************************
  78.  
  79.   Draw the game screen in the given osd_bitmap.
  80.   Do NOT call osd_update_display() from this function, it will be called by
  81.   the main emulation engine.
  82.  
  83. ***************************************************************************/
  84.  
  85. void spacefb_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  86. {
  87.     int offs;
  88.     int spriteno, col_bit2, flipscreen;
  89.  
  90.  
  91.  
  92.     /* Clear the bitmap */
  93.     fillbitmap(bitmap,Machine->pens[0],&Machine->drv->visible_area);
  94.  
  95.     /* Draw the sprite/chars */
  96.     spriteno = (video_control & 0x20) ? 0x80 : 0x00;
  97.     flipscreen = video_control & 0x01;
  98.  
  99.     /* A4 of the color PROM, depending on a jumper setting, can either come
  100.        from the CREF line or from sprite memory. CREF is the default
  101.        according to the schematics */
  102.     col_bit2 = (video_control & 0x40) ? 0x04 : 0x00;
  103.  
  104.     for (offs = 0; offs < 128; offs++, spriteno++)
  105.     {
  106.         int sx,sy,code,cnt,col;
  107.  
  108.  
  109.         sx = 255 - videoram[spriteno];
  110.         sy = videoram[spriteno+0x100];
  111.  
  112.         code = videoram[spriteno+0x200];
  113.         cnt  = videoram[spriteno+0x300];
  114.  
  115.         col = (~cnt & 0x03) | col_bit2;
  116.  
  117.         if (cnt)
  118.         {
  119.             if (cnt & 0x20)
  120.             {
  121.                 /* Draw bullets */
  122.  
  123.                 if (flipscreen)
  124.                 {
  125.                     sx = 260 - sx;
  126.                     sy = 252 - sy;
  127.                 }
  128.  
  129.                 drawgfx(bitmap,Machine->gfx[1],
  130.                         code & 0x3f,
  131.                         col,
  132.                         flipscreen,flipscreen,
  133.                         sx,sy,
  134.                         &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  135.  
  136.             }
  137.             else if (cnt & 0x40)
  138.             {
  139.                 sy -= 5;    /* aligns the spaceship and the bullet */
  140.  
  141.                 if (flipscreen)
  142.                 {
  143.                     sx = 256 - sx;
  144.                     sy = 248 - sy;
  145.                 }
  146.  
  147.                 drawgfx(bitmap,Machine->gfx[0],
  148.                         255 - code,
  149.                         col,
  150.                         flipscreen,flipscreen,
  151.                         sx,sy,
  152.                         &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  153.             }
  154.         }
  155.     }
  156.  
  157. }
  158.